﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC
    {
        public DataRow Convert2WDECK(DataRow dwInput, string AUF, bool IsConvert = false)
        {
            DataSet SResult = new DataSet();
            SResult = QueryABAUFM(dwInput, 0);
            DataRow dwReturn = null;
            if (SResult.Tables[0].Rows.Count > 0)
            {
                dwReturn = SResult.Tables[0].Rows[0];
            }
            else
            {
                dwReturn = SResult.Tables[0].NewRow();
            }
            switch (AUF)
            {
                case "JLT":
                    #region====JLT======
                    dwReturn["WDMANDANT"] = "00";
                    dwReturn["WDSA"] = "V";
                    dwReturn["WDAUFKRS"] = "T6";
                    dwReturn["WDAUFLFD"] = "001326";
                    dwReturn["WDAUFPOS"] = "001";
                    dwReturn["WDTYP"] = "B";
                    dwReturn["WDUPOS"] = "01";
                    dwReturn["WDKUNDNR"] = "00000000";
                    dwReturn["WDWERK"] = "   ";
                    dwReturn["WDABT"] = "   ";
                    dwReturn["WDWAKZ"] = "R";
                    dwReturn["WDART"] = "J4-0003             ";
                    dwReturn["WDDESS"] = "          ";
                    dwReturn["WDCOLORIT"] = "          ";
                    dwReturn["WDFARBE"] = "1         ";
                    dwReturn["WDBESCHICH"] = "          ";
                    dwReturn["WDVAR"] = "  ";
                    dwReturn["WDZUSTAND"] = "    ";
                    dwReturn["WDDAT"] = "20141213";
                    dwReturn["WDLO"] = "  ";
                    dwReturn["WDZS"] = " ";
                    dwReturn["WDAFOLGE"] = "000";
                    dwReturn["WDBEDARF"] = "234500";
                    dwReturn["WDZUGET"] = "0";
                    dwReturn["WDRESERV"] = "0";
                    dwReturn["WDVERBR"] = "0";
                    dwReturn["WDANZSTK"] = "000";
                    dwReturn["WDKZBEDARF"] = " ";
                    dwReturn["WDURAUFKRS"] = "  ";
                    dwReturn["WDURAUFLFD"] = "000000";
                    dwReturn["WDURAUFPOS"] = "000";
                    dwReturn["WDVKNPOS"] = "0";
                    dwReturn["WDPGLKZ"] = " ";
                    dwReturn["WDABRKZ"] = " ";
                    dwReturn["WDDISPOKZ"] = " ";
                    dwReturn["WDERLKZ"] = " ";
                    dwReturn["WDSLPOS"] = "0";
                    dwReturn["WDPRART"] = "J4-0003             ";
                    dwReturn["WDPRVAR"] = "  ";
                    dwReturn["WDBEDBAS"] = "00000000";
                    dwReturn["WDLAGE"] = "00";
                    dwReturn["WDVARFR"] = "J";
                    dwReturn["WDBEDST"] = "M";
                    dwReturn["WDFILLER"] = "0000000000000  ";

                    #endregion
                    break;
                default:
                    #region====default======
                    #endregion
                    break;
            }
            if (IsConvert)
            {
                foreach (DataColumn cm in dwInput.Table.Columns)
                {
                    if (dwInput[cm.ColumnName].ToString() == "")
                        continue;
                    if (dwInput.Table.Columns.Contains(cm.ColumnName))
                    {
                        dwReturn[cm.ColumnName] = dwInput[cm.ColumnName];
                    }
                }
            }
            return dwReturn;
        }
        public void MapWDECK(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void SaveWDECK(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryWDECK(dwData, 5);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapWDECK(ref dwLocal, dwData);

            if (!flgExist)
            {
                InsertWDECK(dwLocal);
            }
            UpdateWDECK(dwLocal);
        }
        public void InsertWDECK(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "INSERT INTO WDECK(WDMANDANT, WDSA, WDAUFKRS, WDAUFLFD, WDAUFPOS, WDTYP, WDUPOS, WDKUNDNR, WDWERK, WDABT, WDWAKZ, WDART, WDDESS, WDCOLORIT, WDFARBE, WDBESCHICH, WDVAR, WDZUSTAND, WDDAT, WDLO, WDZS, WDAFOLGE, WDBEDARF, WDZUGET, WDRESERV, WDVERBR, WDANZSTK, WDKZBEDARF, WDURAUFKRS, WDURAUFLFD, WDURAUFPOS, WDVKNPOS, WDPGLKZ, WDABRKZ, WDDISPOKZ, WDERLKZ, WDSLPOS, WDPRART, WDPRVAR, WDBEDBAS, WDLAGE, WDVARFR, WDBEDST, WDFILLER)"
                                                            + "  VALUES (:WDMANDANT, :WDSA,     :WDAUFKRS,:WDAUFLFD, :WDAUFPOS, :WDTYP,:WDUPOS,            '00000000', '   ',              '   ',           ' ',       '                    ', '          ', '          ', '          ', '          ', '  ', '    ', '        ', '  ', ' ', '000', 0, 0, 0, 0, '000', ' ', '  ', '000000', '000', 0, ' ', ' ', ' ', ' ', 0, '                    ', '  ', '00000000', '00', ' ', ' ', '0000000000000  ')";
            or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
            or1.Parameters.Add("WDSA", OracleType.NVarChar).Value = dwData["WDSA"].ToString();
            or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
            or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
            or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
            or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
            or1.Parameters.Add("WDUPOS", OracleType.NVarChar).Value = dwData["WDUPOS"].ToString();
            Connect2Proxy(or1);
        }
        public void DeleteWDECK(string client, string krs, string lfd, string pos, string upos = "", int option = 1)
        {
            OracleCommand or1 = OracleDB.CreateCommand();

            switch (option)
            {
                case 1:
                    or1.CommandText = "DELETE WDECK "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = client;
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = krs;
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = lfd;
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = pos;
                    break;
                case 2:
                    or1.CommandText = "DELETE WDECK "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD ";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = client;
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = krs;
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = lfd;
                    break;
                case 3:
                    or1.CommandText = "DELETE WDECK "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS AND WDUPOS=:WDUPOS ";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = client;
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = krs;
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = lfd;
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = pos;
                    or1.Parameters.Add("WDUPOS", OracleType.NVarChar).Value = upos;
                    break;
                default:
                    break;
            }
            Connect2Proxy(or1);
        }
        public void DeleteWDECK(DataRow dwData, int option = 1)
        {
            OracleCommand or1 = OracleDB.CreateCommand();

            switch (option)
            {
                case 1:
                    or1.CommandText = "DELETE WDECK "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS AND WDART=:WDART";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"];
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"];
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"];
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"];
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"];
                    break;
                default:
                    break;
            }
            Connect2Proxy(or1);
        }
        public DataSet QueryWDECK(DataRow dwData, int option = 1)
        {
            DataSet Return;
            DataSet Result = new DataSet();
            OracleCommand or1 = OracleDB.CreateCommand();
            string FSARTPRGR = "";
            switch (option)
            {
                case 0:
                    or1.CommandText = "SELECT * FROM WDECK WHERE  ROWNUM<2 ";
                    break;
                case 1:
                    or1.CommandText = "SELECT * FROM WDECK  "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP='B' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT * FROM WDECK  "
                    + " WHERE WDMANDANT=:WDMANDANT AND WDTYP='B' AND WDART=:WDART  AND WDFARBE=:WDFARBE";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    or1.Parameters.Add("WDFARBE", OracleType.NVarChar).Value = dwData["WDFARBE"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM WDECK  "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    break;
                case 4:
                    or1.CommandText = "SELECT DISTINCT WDMANDANT,WDSA,WDUPOS,WDAUFKRS,WDAUFLFD,WDAUFPOS"
                        + " ,WDWAKZ,WDART,WDFARBE,WDBESCHICH,WDVAR,TO_CHAR(VKPLIEFTERM) AS WDDAT,VKPMENGE1*VKPMEEHFKT*0.001*0.001 AS WDBEDARF"
                        + ",VKPSACHBE,VKPKUNDNR,VKPVB,VKPVG,VKPLAEBIS,VKPLAEVON,VKPAUFMART"
                        + " FROM WDECK JOIN VKPOS ON"
                        + " WDSA='K' AND WDAUFKRS=VKPAUFKRS AND WDAUFLFD=VKPAUFLFD AND WDAUFPOS=VKPAUFPOS AND VKPSA='  '"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='K' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                case 5:
                    or1.CommandText = "SELECT * FROM WDECK  "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS AND WDUPOS=:WDUPOS";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    or1.Parameters.Add("WDUPOS", OracleType.NVarChar).Value = dwData["WDUPOS"].ToString();
                    break;
                case 6:
                    or1.CommandText = "SELECT * FROM WDECK  "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='V' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;

                case 7:
                    or1.CommandText = "SELECT DISTINCT ABKMANDANT, ABKAUFKRS,ABKAUFLFD,ABPART,FSABEZ,LSLIEFNA AS EXTPRODUCER,ABPLIEFNR,ABPANRKR,ABPALFDNR  "
                    + " FROM WDECK F JOIN ABKOPF K ON F.WDAUFKRS=K.ABKAUFKRS AND  F.WDAUFLFD=K.ABKAUFLFD"
                    + " JOIN ABPOS P ON F.WDAUFKRS=P.ABPAUFKRS AND  F.WDAUFLFD=P.ABPAUFLFD AND  F.WDAUFPOS=P.ABPAUFPOS AND ABPGESSTA='SP'"
                    + " LEFT JOIN FSSTAMM M ON ABPART=FSART"
                            + " LEFT JOIN LIEFDAT M ON LSLIEFNR=ABPLIEFNR "
                    + " WHERE F.WDART=:WDART AND F.WDTYP=:WDTYP";
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    break;
                case 8:
                    or1.CommandText = "SELECT WD.*, WAUEBM as UM,WAFGRLFD as FGRLFD,0 AS RATIO FROM WDECK WD"
                        + " LEFT JOIN WASTAMM T ON  WD.WDART=T.WAART AND WDVAR=WAVAR"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='V' AND WDTYP='B' AND WDWAKZ='F' AND "
                        + " WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                case 9://分组 
                    FSARTPRGR = dwData["WDART"].ToString().Trim();
                    or1.CommandText = "SELECT WDMANDANT AS MANDANT,WDTYP AS DTYP,WDART AS ART,WDVAR AS VAR,WDFARBE AS COLOR,"
                        + " MAX(Trim(WAFBEZ)) AS CDES, '       ' AS ASIZE,ABACOLORREF AS CREF,MAX(S.WAUEBM) AS UM,MAX(Trim(S.WABEZ))AS ARTDES,"
                        + "SUM(ABARESMG) AS REQ,MAX(S.WAFGRLFD) AS FGRLFD,SUM(ABARESMG) AS MTRREQ,"
                        + "NVL(MAX(SP.LSLIEFNA),'YCA') AS SELLER,NVL(MAX(SP.LSNAME1),'YCA') AS SELLERNAME "
                        + " FROM INTEX.WDECK R JOIN INTEX.ICC_ABAUFM M"
                        + "  ON R.WDAUFKRS=M.ABAVKAUFKRS AND R.WDAUFLFD=M.ABAVKAUFLFD AND R.WDAUFPOS=M.ABAVKAUFPOS"
                        + " AND R.WDUPOS=M.ABAVKUPOS AND ABAART=WDART AND WDVAR=ABAVAR AND ABAFARBE=WDFARBE"
                        + " LEFT JOIN WASTAMM S ON R.WDART=S.WAART AND R.WDVAR=S.WAVAR"
                        + " LEFT JOIN WAFARBEN F ON R.WDART=WAFART AND R.WDVAR=WAFVAR AND WDFARBE=WAFZUSATZ "
                        + " LEFT JOIN LIEFDAT SP ON WALIEFNR=SP.LSLIEFNR"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP AND WDZUGET=0 AND WDRESERV=0 AND M.ABAAUFTYP='N' AND M.FSARTPRGR IN (" + FSARTPRGR + ")"
                        + " GROUP BY WDMANDANT,WDTYP,WDART,WDVAR,WDFARBE,ABACOLORREF"
                        + " ORDER BY WDMANDANT,WDTYP,WDART,WDVAR,WDFARBE,ABACOLORREF";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    break;
                case 91://分组 
                    FSARTPRGR = dwData["C20"].ToString().Trim();
                    or1.CommandText = "SELECT FSSZUSCHN,WDMANDANT AS MANDANT,WDTYP AS DTYP,WDART AS ART,WDVAR AS VAR,WDFARBE AS COLOR,"
                        + " MAX(Trim(WAFBEZ)) AS CDES, '       ' AS ASIZE,ABACOLORREF AS CREF,MAX(S.WAUEBM) AS UM,MAX(Trim(S.WABEZ))AS ARTDES,"
                        + "SUM(ABARESMG) AS REQ,MAX(S.WAFGRLFD) AS FGRLFD,SUM(ABARESMG) AS MTRREQ,"
                        + "NVL(MAX(SP.LSLIEFNA),'YCA') AS SELLER,NVL(MAX(SP.LSNAME1),'YCA') AS SELLERNAME,MAX(EXART) AS EXART,MAX(EXCOLOR) AS EXCOLOR,'0' AS PLANRATE,'0' AS WASTAGEEK "
                        + " FROM INTEX.WDECK R JOIN INTEX.ICC_ABAUFM M"
                        + "  ON R.WDAUFKRS=M.ABAVKAUFKRS AND R.WDAUFLFD=M.ABAVKAUFLFD AND R.WDAUFPOS=M.ABAVKAUFPOS"
                        + " AND R.WDUPOS=M.ABAVKUPOS AND ABAART=WDART AND WDVAR=ABAVAR AND ABAFARBE=WDFARBE"
                        + " LEFT JOIN WASTAMM S ON R.WDART=S.WAART AND R.WDVAR=S.WAVAR"
                        + " LEFT JOIN WAFARBEN F ON R.WDART=WAFART AND R.WDVAR=WAFVAR AND WDFARBE=WAFZUSATZ "
                        + " LEFT JOIN LIEFDAT SP ON WALIEFNR=SP.LSLIEFNR"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP AND "
                        + " WDZUGET=0 AND WDRESERV=0 AND M.ABAAUFTYP='N' AND M. FSSZUSCHN=:FSSZUSCHN AND M.FSARTPRGR " + FSARTPRGR + ""
                        + " GROUP BY WDMANDANT,WDTYP,WDART,WDVAR,WDFARBE,FSSZUSCHN,ABACOLORREF"
                        + " ORDER BY WDMANDANT,WDTYP,WDART,WDVAR,WDFARBE,FSSZUSCHN,ABACOLORREF";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["C1"].ToString();
                    break;
                case 92://分组 
                    or1.CommandText = "SELECT WDMANDANT AS MANDANT,WDTYP AS DTYP,WDART AS ART,WDVAR AS VAR,WDFARBE AS COLOR,"
                        + " MAX(Trim(WAFBEZ)) AS CDES, '       ' AS ASIZE,ABACOLORREF AS CREF,MAX(S.WAUEBM) AS UM,MAX(Trim(S.WABEZ))AS ARTDES,"
                        + "SUM(ABARESMG) AS REQ,MAX(S.WAFGRLFD) AS FGRLFD,SUM(ABARESMG) AS MTRREQ,"
                        + "NVL(MAX(SP.LSLIEFNA),'YCA') AS SELLER,NVL(MAX(SP.LSNAME1),'YCA') AS SELLERNAME,FSSZUSCHN,M.ABPART,MAX(EXART) AS EXART,MAX(EXCOLOR) AS EXCOLOR ,'0' AS PLANRATE,'0' AS WASTAGEEK "
                        + " FROM INTEX.WDECK R JOIN INTEX.ICC_ABAUFM M ON R.WDAUFKRS=M.ABAVKAUFKRS AND R.WDAUFLFD=M.ABAVKAUFLFD AND R.WDAUFPOS=M.ABAVKAUFPOS"
                        + " AND R.WDUPOS=M.ABAVKUPOS AND ABAART=WDART AND WDVAR=ABAVAR AND ABAFARBE=WDFARBE"
                        + " LEFT JOIN WASTAMM S ON R.WDART=S.WAART AND R.WDVAR=S.WAVAR"
                        + " LEFT JOIN WAFARBEN F ON R.WDART=WAFART AND R.WDVAR=WAFVAR AND WDFARBE=WAFZUSATZ "
                        + " LEFT JOIN LIEFDAT SP ON WALIEFNR=SP.LSLIEFNR"
                        + " JOIN ABPOS P ON WDAUFKRS=ABPAUFKRS  AND WDAUFLFD=ABPAUFLFD    AND WDAUFPOS=ABPAUFPOS AND  ABPSPGRD<='89' "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP AND WDZUGET=0 AND WDRESERV=0 AND M.ABAAUFTYP='N' AND M.FSSZUSCHN=:FSSZUSCHN "
                        + " GROUP BY WDMANDANT,WDTYP,WDART,WDVAR,WDFARBE,ABACOLORREF,FSSZUSCHN,M.ABPART"
                        + " ORDER BY ABPART,FSSZUSCHN,WDART,WDVAR,WDFARBE,ABACOLORREF";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    or1.Parameters.Add("FSSZUSCHN", OracleType.NVarChar).Value = dwData["WDSA"].ToString();
                    break;
                case 10:
                    or1.CommandText = "SELECT ABPAUFKRS,ABPAUFLFD,ABPAUFPOS,ABPART,ABPFARBE,ABPGROE,ABPSOLLMENGE7,WD.* "
                    + " FROM WDECK WD JOIN ABPOS P ON WDAUFKRS=ABPAUFKRS AND WDAUFLFD=ABPAUFLFD AND WDAUFPOS=ABPAUFPOS  "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDART=:WDART";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    break;

                case 11:
                    string sections = dwData["WDART"].ToString().Trim();
                    if (sections == "''")
                    {
                        sections = "NOT IN ('   ')";
                    }
                    else
                    {
                        sections = "IN (" + sections + ") ";
                    }
                    or1.CommandText = "SELECT DISTINCT WDART FROM WDECK LEFT JOIN ABPOS ON WDAUFKRS=ABPAUFKRS AND WDAUFLFD=ABPAUFLFD AND WDAUFPOS=ABPAUFPOS"
                        + " LEFT JOIN FSSTUELI ON ABPART=FSSART AND WDART=FSSMART "
                        + " JOIN FSSTAMM M ON FSART=ABPART "
                        + " WHERE  ABPSPGRD>'89' AND FSSZUSCHN='J' AND M.FSARTPRGR " + sections
                        + " AND WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    break;
                case 12:
                    or1.CommandText = "SELECT WD.* FROM WDECK WD "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD "
                        + " AND  WDART=:WDART AND WDVAR=:WDVAR AND WDFARBE=:WDFARBE";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    or1.Parameters.Add("WDVAR", OracleType.NVarChar).Value = dwData["WDVAR"].ToString();
                    or1.Parameters.Add("WDFARBE", OracleType.NVarChar).Value = dwData["WDFARBE"].ToString();
                    break;
                case 13:
                    or1.CommandText = "SELECT WD.*, WAUEBM as UM,WAFGRLFD as FGRLFD,0 AS RATIO FROM WDECK WD"
                        + " LEFT JOIN WASTAMM T ON  WD.WDART=T.WAART AND WDVAR=WAVAR"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='V' AND WDTYP='B' AND WDWAKZ='F' AND "
                        + " WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    break;
                case 14:
                    or1.CommandText = "SELECT WD.* FROM WDECK WD "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD "
                        + " AND  WDART=:WDART  ";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    break;
                case 15:
                    or1.CommandText = "SELECT * FROM WDECK  "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS ";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    break;
                case 16:
                    or1.CommandText = "SELECT DISTINCT WDART FROM EKPOS EK JOIN WDECK WD ON "
                        + " EKPSA<>'AJ'  AND utl_raw.cast_to_varchar2(EKPART)=WD.WDART  "
                        + " AND utl_raw.cast_to_varchar2(EKPFARBE)=WD.WDFARBE   AND EKPBEKZ=:EKPBEKZ"
                        + " JOIN ABPOS ON ABPAUFKRS=WDAUFKRS AND ABPAUFLFD=WDAUFLFD AND ABPAUFPOS=WDAUFPOS"
                        + " JOIN FSSTAMM M ON FSART=ABPART"
                        + " JOIN FSSTUELI ON ABPART=FSSART AND WDART=FSSMART AND FSSZUSCHN<>'J' AND "
                        + " M.FSARTPRGR IN  (" + dwData["WDART"].ToString().Trim() + ")"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDTYP=:WDTYP";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    or1.Parameters.Add("EKPBEKZ", OracleType.NVarChar).Value = dwData["WDSA"].ToString();
                    break;
                case 17:
                    or1.CommandText = "SELECT ABPAUFKRS,ABPAUFLFD,ABPAUFPOS,ABPART,ABPFARBE,ABPGROE,ABPSOLLMENGE7,WD.* "
                    + " FROM WDECK WD JOIN ABPOS P ON WDAUFKRS=ABPAUFKRS AND WDAUFLFD=ABPAUFLFD AND WDAUFPOS=ABPAUFPOS  "
                        + " WHERE WDMANDANT=:WDMANDANT AND ABPART=:WDART AND WDART=:WDPRART";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    or1.Parameters.Add("WDPRART", OracleType.NVarChar).Value = dwData["WDPRART"].ToString();
                    break;
                case 18:
                    or1.CommandText = "SELECT * FROM WDECK  "
                        + " WHERE WDMANDANT=:WDMANDANT  AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    break;
                case 19:
                    or1.CommandText = "SELECT  WDAUFKRS,WDAUFLFD,WDAUFPOS,WDUPOS,WDART,WDFARBE,"
                    + "ABPFARBE,ABARESMG,ABAQTYRESERVE,EKPAUFKRS,EKPAUFLFD,EKPAUFPOS,EKPME1,EKPME3 FROM WDECK"
                        + " LEFT JOIN ICC_ABAUFM ON WDAUFKRS=ABAVKAUFKRS AND WDAUFLFD=ABAVKAUFLFD AND WDAUFPOS=ABAVKAUFPOS"
                        + " AND WDART=ABAART AND WDFARBE=ABAFARBE"
                        + " LEFT JOIN EKPOS ON EKPAUFKRS=ABAAUFKRS AND EKPAUFLFD=ABAAUFLFD AND EKPAUFPOS=ABAAUFPOS AND EKPSA='PO'"
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='V' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                case 20:
                    or1.CommandText = "SELECT WD.*, WAUEBM as UM,WAFGRLFD as FGRLFD,0 AS RATIO FROM WDECK WD"
                        + " LEFT JOIN WASTAMM T ON  WD.WDART=T.WAART AND WDVAR=WAVAR"
                        + " LEFT JOIN ABPOS P ON  WDMANDANT=ABPMANDANT AND WD.WDAUFKRS=P.ABPAUFKRS AND WDAUFLFD=ABPAUFLFD AND WDAUFPOS=ABPAUFPOS"
                        + " WHERE  WDSA='V' AND WDTYP='B' AND WDWAKZ='F' AND "
                        + " ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS  AND ABPAUFLFD=:ABPAUFLFD AND ABPART=:ABPART AND ABPFARBE=:ABPFARBE";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwData["ABPAUFKRS"].ToString();
                    or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwData["ABPAUFLFD"].ToString();
                    or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwData["ABPART"].ToString();
                    or1.Parameters.Add("ABPFARBE", OracleType.NVarChar).Value = dwData["ABPFARBE"].ToString();
                    break;
                case 21:
                    or1.CommandText = "SELECT * FROM WDECK  "
                        + " WHERE WDMANDANT=:WDMANDANT   AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD  ";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                case 22:
                    or1.CommandText = "SELECT ABPMANDANT,ABPAUFKRS,NVL(ABPAUFLFD,'000000') AS ABPAUFLFD,ABPAUFPOS,WDART AS ABPART,WDFARBE AS ABPFARBE,WDVAR AS ABPVAR,WDBESCHICH AS ABPBESCHICH  FROM WDECK WD LEFT JOIN ABPOS P ON  WDWAKZ=ABPWAKZ AND ABPART=WDART AND ABPFARBE=WDFARBE AND ABPBESCHICH=WDBESCHICH  "
                        + " WHERE WDWAKZ=:WDWAKZ AND WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS ";
                    or1.Parameters.Add("WDWAKZ", OracleType.NVarChar).Value = dwData["C1"].ToString();
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["VKPMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["VKPAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["VKPAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["VKPAUFPOS"].ToString();
                    break;
                case 99:
                    or1.CommandText = "SELECT WDMANDANT,WDAUFKRS,WDAUFLFD,WDAUFPOS,WDSA,WDUPOS,WDART,WDDESS,WDCOLORIT,WDFARBE,WDBESCHICH,WDVAR"
                    + ", WAUEBM as UM,WAFGRLFD as FGRLFD,WABEZ AS ARTDES,WAFBEZ AS CDES,WDBEDARF,WDZUGET,WDRESERV,0 AS RATIO"
                        + "  FROM WDECK  WD LEFT JOIN WASTAMM T ON  WD.WDART=T.WAART AND WDVAR=WAVAR"
                        + " LEFT JOIN WAFARBEN ON WAFART=WDART AND WAFVAR=WDVAR AND WAFZUSATZ=WDFARBE "
                        + " WHERE WDMANDANT=:WDMANDANT AND WDSA='V' AND WDTYP='B' AND WDWAKZ='F' AND WDAUFKRS=:WDAUFKRS  AND WDAUFLFD=:WDAUFLFD"
                        + " ORDER BY WDMANDANT,WDAUFKRS,WDAUFLFD,WDAUFPOS,WDART,WDDESS,WDCOLORIT,WDFARBE,WDBESCHICH";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    break;
                default:
                    break;
            }
            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
                Result.Tables[0].TableName = "WDECK";
            Return = Result;
            return Return;
        }
        public void UpdateWDECK(DataRow dwData, string ITXDBVERSION = "50.24", int option = 1)
        {
            OracleCommand or1;
            DataSet result = new DataSet();
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    or1.CommandText = "UPDATE WDECK SET "
                   + "WDMANDANT=:WDMANDANT,"
                   + "WDSA=:WDSA,"
                   + "WDAUFKRS=:WDAUFKRS,"
                   + "WDAUFLFD=:WDAUFLFD,"
                   + "WDAUFPOS=:WDAUFPOS,"
                   + "WDTYP=:WDTYP,"
                   + "WDUPOS=:WDUPOS,"
                   + "WDKUNDNR=:WDKUNDNR,"
                   + "WDWERK=:WDWERK,"
                   + "WDABT=:WDABT,"
                   + "WDWAKZ=:WDWAKZ,"
                   + "WDART=:WDART,"
                   + "WDDESS=:WDDESS,"
                   + "WDCOLORIT=:WDCOLORIT,"
                   + "WDFARBE=:WDFARBE,"
                   + "WDBESCHICH=:WDBESCHICH,"
                   + "WDVAR=:WDVAR,"
                   + "WDZUSTAND=:WDZUSTAND,"
                   + "WDDAT=:WDDAT,"
                   + "WDLO=:WDLO,"
                   + "WDZS=:WDZS,"
                   + "WDAFOLGE=:WDAFOLGE,"
                   + "WDBEDARF=:WDBEDARF,"
                   + "WDZUGET=:WDZUGET,"
                   + "WDRESERV=:WDRESERV,"
                   + "WDVERBR=:WDVERBR,"
                   + "WDANZSTK=:WDANZSTK,"
                   + "WDKZBEDARF=:WDKZBEDARF,"
                   + "WDURAUFKRS=:WDURAUFKRS,"
                   + "WDURAUFLFD=:WDURAUFLFD,"
                   + "WDURAUFPOS=:WDURAUFPOS,"
                   + "WDVKNPOS=:WDVKNPOS,"
                   + "WDPGLKZ=:WDPGLKZ,"
                   + "WDABRKZ=:WDABRKZ,"
                   + "WDDISPOKZ=:WDDISPOKZ,"
                   + "WDERLKZ=:WDERLKZ,"
                   + "WDSLPOS=:WDSLPOS,"
                   + "WDPRART=:WDPRART,"
                   + "WDPRVAR=:WDPRVAR,"
                   + "WDBEDBAS=:WDBEDBAS,"
                   + "WDLAGE=:WDLAGE,"
                   + "WDVARFR=:WDVARFR,"
                   + "WDBEDST=:WDBEDST,"
                   + "WDFILLER=:WDFILLER "
              + " WHERE  "
              + "  WDMANDANT=:WDMANDANT AND WDSA=:WDSA AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS AND WDTYP=:WDTYP AND WDUPOS=:WDUPOS";


                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDSA", OracleType.NVarChar).Value = dwData["WDSA"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    or1.Parameters.Add("WDTYP", OracleType.NVarChar).Value = dwData["WDTYP"].ToString();
                    or1.Parameters.Add("WDUPOS", OracleType.NVarChar).Value = dwData["WDUPOS"].ToString();
                    or1.Parameters.Add("WDKUNDNR", OracleType.NVarChar).Value = dwData["WDKUNDNR"].ToString();
                    or1.Parameters.Add("WDWERK", OracleType.NVarChar).Value = dwData["WDWERK"].ToString();
                    or1.Parameters.Add("WDABT", OracleType.NVarChar).Value = dwData["WDABT"].ToString();
                    or1.Parameters.Add("WDWAKZ", OracleType.NVarChar).Value = dwData["WDWAKZ"].ToString();
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    or1.Parameters.Add("WDDESS", OracleType.NVarChar).Value = dwData["WDDESS"].ToString();
                    or1.Parameters.Add("WDCOLORIT", OracleType.NVarChar).Value = dwData["WDCOLORIT"].ToString();
                    or1.Parameters.Add("WDFARBE", OracleType.NVarChar).Value = dwData["WDFARBE"].ToString();
                    or1.Parameters.Add("WDBESCHICH", OracleType.NVarChar).Value = dwData["WDBESCHICH"].ToString();
                    or1.Parameters.Add("WDVAR", OracleType.NVarChar).Value = dwData["WDVAR"].ToString();
                    or1.Parameters.Add("WDZUSTAND", OracleType.NVarChar).Value = dwData["WDZUSTAND"].ToString();
                    or1.Parameters.Add("WDDAT", OracleType.NVarChar).Value = dwData["WDDAT"].ToString();
                    or1.Parameters.Add("WDLO", OracleType.NVarChar).Value = dwData["WDLO"].ToString();
                    or1.Parameters.Add("WDZS", OracleType.NVarChar).Value = dwData["WDZS"].ToString();
                    or1.Parameters.Add("WDAFOLGE", OracleType.NVarChar).Value = dwData["WDAFOLGE"].ToString();
                    or1.Parameters.Add("WDBEDARF", OracleType.NVarChar).Value = dwData["WDBEDARF"].ToString();
                    or1.Parameters.Add("WDZUGET", OracleType.NVarChar).Value = dwData["WDZUGET"].ToString();
                    or1.Parameters.Add("WDRESERV", OracleType.NVarChar).Value = dwData["WDRESERV"].ToString();
                    or1.Parameters.Add("WDVERBR", OracleType.NVarChar).Value = dwData["WDVERBR"].ToString();
                    or1.Parameters.Add("WDANZSTK", OracleType.NVarChar).Value = dwData["WDANZSTK"].ToString();
                    or1.Parameters.Add("WDKZBEDARF", OracleType.NVarChar).Value = dwData["WDKZBEDARF"].ToString();
                    or1.Parameters.Add("WDURAUFKRS", OracleType.NVarChar).Value = dwData["WDURAUFKRS"].ToString();
                    or1.Parameters.Add("WDURAUFLFD", OracleType.NVarChar).Value = dwData["WDURAUFLFD"].ToString();
                    or1.Parameters.Add("WDURAUFPOS", OracleType.NVarChar).Value = dwData["WDURAUFPOS"].ToString();
                    or1.Parameters.Add("WDVKNPOS", OracleType.NVarChar).Value = dwData["WDVKNPOS"].ToString();
                    or1.Parameters.Add("WDPGLKZ", OracleType.NVarChar).Value = dwData["WDPGLKZ"].ToString();
                    or1.Parameters.Add("WDABRKZ", OracleType.NVarChar).Value = dwData["WDABRKZ"].ToString();
                    or1.Parameters.Add("WDDISPOKZ", OracleType.NVarChar).Value = dwData["WDDISPOKZ"].ToString();
                    or1.Parameters.Add("WDERLKZ", OracleType.NVarChar).Value = dwData["WDERLKZ"].ToString();
                    or1.Parameters.Add("WDSLPOS", OracleType.NVarChar).Value = dwData["WDSLPOS"].ToString();
                    or1.Parameters.Add("WDPRART", OracleType.NVarChar).Value = dwData["WDPRART"].ToString();
                    or1.Parameters.Add("WDPRVAR", OracleType.NVarChar).Value = dwData["WDPRVAR"].ToString();
                    or1.Parameters.Add("WDBEDBAS", OracleType.NVarChar).Value = dwData["WDBEDBAS"].ToString();
                    or1.Parameters.Add("WDLAGE", OracleType.NVarChar).Value = dwData["WDLAGE"].ToString();
                    or1.Parameters.Add("WDVARFR", OracleType.NVarChar).Value = dwData["WDVARFR"].ToString();
                    or1.Parameters.Add("WDBEDST", OracleType.NVarChar).Value = dwData["WDBEDST"].ToString();
                    or1.Parameters.Add("WDFILLER", OracleType.NVarChar).Value = dwData["WDFILLER"].ToString();
                    break;
                case 2:
                    or1.CommandText = "UPDATE WDECK SET WDBEDARF=:WDBEDARF "
                        + " WHERE  "
                        + "  WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD AND WDAUFPOS=:WDAUFPOS AND WDART=:WDART AND WDVAR=:WDVAR"
                        + " AND WDFARBE=:WDFARBE";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    or1.Parameters.Add("WDFARBE", OracleType.NVarChar).Value = dwData["WDFARBE"].ToString();
                    or1.Parameters.Add("WDVAR", OracleType.NVarChar).Value = dwData["WDVAR"].ToString();
                    or1.Parameters.Add("WDBEDARF", OracleType.NVarChar).Value = dwData["WDBEDARF"].ToString();
                    break;
                case 3:
                    /*
                     *   UPDATE WDECK A SET WDDAT = (
SELECT DECODE(B.VKPFREITERM,0,B.VKPWUTERM,B.VKPFREITERM) FROM VKPOS B
WHERE VKPSA <>'AJ' AND B.VKPMANDANT = A.WDMANDANT AND B.VKPAUFKRS = A.WDAUFKRS
AND B.VKPAUFLFD = A.WDAUFLFD AND B.VKPAUFPOS = A.WDAUFPOS )
WHERE A.WDSA = 'K' AND A.WDAUFKRS = 
AND A.WDAUFLFD =  AND A.WDAUFPOS =
                     */
                    or1.CommandText = "UPDATE WDECK A SET WDDAT = (SELECT DECODE(B.VKPFREITERM,0,B.VKPWUTERM,B.VKPFREITERM) FROM VKPOS B"
                        + " WHERE VKPSA <>'AJ' AND B.VKPMANDANT = A.WDMANDANT AND B.VKPAUFKRS = A.WDAUFKRS"
                        + " AND B.VKPAUFLFD = A.WDAUFLFD AND B.VKPAUFPOS = A.WDAUFPOS )"
                        + " WHERE A.WDSA = 'K' AND WDMANDANT=:WDMANDANT AND A.WDAUFKRS =:WDAUFKRS AND A.WDAUFLFD =:WDAUFLFD  AND A.WDAUFPOS =:WDAUFPOS";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDAUFPOS", OracleType.NVarChar).Value = dwData["WDAUFPOS"].ToString();
                    break;
                case 4:
                    or1.CommandText = "UPDATE WDECK SET WDANZSTK=:WDANZSTK "
                        + " WHERE  "
                        + "  WDMANDANT=:WDMANDANT AND WDAUFKRS=:WDAUFKRS AND WDAUFLFD=:WDAUFLFD  AND WDART=:WDART  AND WDFARBE=:WDFARBE";
                    or1.Parameters.Add("WDMANDANT", OracleType.NVarChar).Value = dwData["WDMANDANT"].ToString();
                    or1.Parameters.Add("WDAUFKRS", OracleType.NVarChar).Value = dwData["WDAUFKRS"].ToString();
                    or1.Parameters.Add("WDAUFLFD", OracleType.NVarChar).Value = dwData["WDAUFLFD"].ToString();
                    or1.Parameters.Add("WDART", OracleType.NVarChar).Value = dwData["WDART"].ToString();
                    or1.Parameters.Add("WDFARBE", OracleType.NVarChar).Value = dwData["WDFARBE"].ToString();
                    or1.Parameters.Add("WDANZSTK", OracleType.NVarChar).Value = dwData["WDANZSTK"].ToString();
                    break;
            }

            Connect2Proxy(or1);
        }
    }
}
